package com.lww.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.lww.entity.User;
import com.lww.service.UserService;
import com.lww.service.impl.UserServiceImpl;

/**
 * Servlet implementation class UserServlet
 */
public class UserServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
    
	public String findAllUser(HttpServletRequest request,HttpServletResponse response) {
		UserService userService = new UserServiceImpl();
		List<User> list = userService.findAllUser();
		request.setAttribute("list", list);
		return "rq:index.jsp";
	}
	
	public String deleteUser(HttpServletRequest request,HttpServletResponse response) {
		UserService userService = new UserServiceImpl();
		userService.deleteUser(Integer.parseInt(request.getParameter("id")));
		String result = findAllUser(request, response);
		return result;
	}

}
